<!--
 * @Author: 宋杰
 * @Date: 2021-03-13 22:08:34
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-03-16 23:40:59
 * @Description: 一家十一口(猜一字)
-->
<template>
  <div class="divBox">
    <div class="titleBox">
      <div>交易耗时排名（ms）</div>
    </div>
    <div>
      <div ref="rightBottomBox" style="width:100%; height: 100%;"></div>
    </div>
  </div>
</template>

<script>
//import {} from '';
export default {
  name: "",
  data() {
    return {};
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  mounted() {
    this.draw();
  },
  methods: {
    draw() {
      // 基于准备好的dom，初始化echarts
      var chartDom = this.$refs.rightBottomBox;
      const myChart = this.$echarts.init(chartDom);
      var option;

      option = {
        // title: {
        //   text: "世界人口总量",
        //   subtext: "数据来自网络",
        // },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        // legend: {
        //   data: ["蚂蚁授信交易", "京东授信交易", "美团授信交易", "小米授信交易", "滴滴授信交易",]
        // },
        grid: {
          left: "5%",
          // right: "2%",
          height: "75%",
          containLabel: true,
        },
        xAxis: {
          type: "value",
          boundaryGap: [0, 0.01],
          splitLine: {
            show: false,
          },
          // y轴线样式
          axisLine: {
            show: false,
          },
          // 刻度
          axisTick: {
            show: false,
          },
          // 刻度标签
          axisLabel: {
            show: false,
          },
        },
        yAxis: {
          type: "category",
          inverse: true,
          data: [
            "蚂蚁授信交易",
            "京东授信交易",
            "美团授信交易",
            "小米授信交易",
            "滴滴授信交易",
          ],
          // y轴线样式
          axisLine: {
            lineStyle: {
              color: "#2F9CDF",
              width: 4,
            },
          },
          // 刻度
          axisTick: {
            show: false,
          },
          // 刻度标签
          axisLabel: {
            color: "#68D5EA",
            fontSize: 20,
            margin: 20, //文字和线之间的距离
          },
        },
        series: [
          {
            name: "",
            type: "bar",
            barWidth: "30%", //宽度
            itemStyle: {
              barBorderRadius: [0, 20, 20, 0], //设置圆角
            },
            // 柱子上的文字标签
            label: {
              show: true,
              position: "right",
              distance: 15.5,
              color: "#68D5EA",
              fontSize: 20,
            },
            data: [
              {
                value: 200,
                name: "蚂蚁授信交易",

                itemStyle: {
                  normal: {
                    color: new this.$echarts.graphic.LinearGradient(
                      0,
                      1,
                      0,
                      0,
                      [
                        {
                          offset: 0,
                          color: "#2F9CDF", // 0% 处的颜色
                        },
                        {
                          offset: 1,
                          color: "#68D5EA", // 100% 处的颜色
                        },
                      ],
                      false
                    ),
                  },
                },
              },

              {
                value: 360,
                name: "京东授信交易",
                itemStyle: {
                  normal: {
                    color: new this.$echarts.graphic.LinearGradient(
                      0,
                      1,
                      0,
                      0,
                      [
                        {
                          offset: 0,
                          color: "#2F9CDF", // 0% 处的颜色
                        },
                        {
                          offset: 1,
                          color: "#68D5EA", // 100% 处的颜色
                        },
                      ],
                      false
                    ),
                  },
                },
              },

              {
                value: 400,
                name: "美团授信交易",
                itemStyle: {
                  normal: {
                    color: new this.$echarts.graphic.LinearGradient(
                      0,
                      1,
                      0,
                      0,
                      [
                        {
                          offset: 0,
                          color: "#2F9CDF", // 0% 处的颜色
                        },
                        {
                          offset: 1,
                          color: "#68D5EA", // 100% 处的颜色
                        },
                      ],
                      false
                    ),
                  },
                },
              },

              {
                value: 450,
                name: "小米授信交易",
                itemStyle: {
                  normal: {
                    color: new this.$echarts.graphic.LinearGradient(
                      0,
                      1,
                      0,
                      0,
                      [
                        {
                          offset: 0,
                          color: "#2F9CDF", // 0% 处的颜色
                        },
                        {
                          offset: 1,
                          color: "#68D5EA", // 100% 处的颜色
                        },
                      ],
                      false
                    ),
                  },
                },
              },

              {
                value: 550,
                name: "滴滴授信交易",
                itemStyle: {
                  normal: {
                    color: new this.$echarts.graphic.LinearGradient(
                      0,
                      1,
                      0,
                      0,
                      [
                        {
                          offset: 0,
                          color: "#2F9CDF", // 0% 处的颜色
                        },
                        {
                          offset: 1,
                          color: "#68D5EA", // 100% 处的颜色
                        },
                      ],
                      false
                    ),
                  },
                },
              },
            ],
          },
        ],
      };

      option && myChart.setOption(option);
    },
  },
};
</script>
<style lang="scss" scoped>
.divBox {
  width: 100%;
  height: 100%;
  
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  >:nth-child(2) {
    flex: 1;
    width: 100%;
    // border: 1px solid #fff;
    >:nth-child(1) {
      width: 100%;
      height: 100%;
    }
  }
}
.titleBox {
  margin-top: 0.2rem;
  font-family: PingFangSC-Regular;
  font-size: 0.3rem;
  color: #75bdff;
  letter-spacing: 0.015rem;
  text-align: left;
  line-height: 0.5rem;
  height: 0.5rem;
  width: 100%;
  background: url("../../assets/heng2.png") no-repeat;
  background-size: 100% 40%;
  background-position: right 0 bottom 0;
  margin-bottom: 0.05rem;
}
</style>
